/**
 * $Id: SequenceSower.java,v 1.4 2006/09/15 01:50:53 martin Exp $
 *
 * Copyright 2005 Skyinfo, Inc. All Rights Reserved.
 */
package com.haoxi.gateway.sgip12msg;

import java.text.SimpleDateFormat;
import java.util.Date;
import com.haoxi.gateway.runner.RunnerMgr;

public class SequenceSower {
    private static int sequence = 0;
    private static final SimpleDateFormat format = new SimpleDateFormat("MMddHHmmss");
    private static String nodeid = RunnerMgr.getInstance().getGatewayInfo()
            .getUnicom_nodeID();

    public synchronized static void setUnicomSequence(SGIPMessage message) {
        int timeStamp = Integer.parseInt(format.format(new Date()));
        sequence++;
        if (sequence >= 0x7fffffff) {
            sequence = 0;
        }
        message.setSequenceId(sequence);
        message.setSrcNodeId(Long.parseLong(nodeid));
        message.setTimeStamp(timeStamp);
    }
}
